BinaryFBetaScore metric
Bases: FBetaScore
F-beta on boolean fields; use for imbalanced yes/no labels, not text.
Formula:
This is the weighted harmonic mean of precision and recall.
Its output range is [0, 1]. It operates at a field level
and can be used for multi-class and multi-label classification.
Each field of y_true and y_pred should be booleans or floats between [0, 1].
If the fields are floats, it uses the threshold parameter for deciding
if the values are 0 or 1.
Example:
class MultiClassClassification(synalinks.DataModel):
label_1: bool = synalinks.Field(
description="The first label",
)
label_2: bool = synalinks.Field(
description="The second label",
)
label_3: bool = synalinks.Field(
description="The third label",
)
# OR you can also use floats between 0 and 1
# The `Score`, enforce a float between 0.0 and 1.0 using constrained decoding
class MultiClassClassification(synalinks.DataModel):
label_1: synalinks.Score = synalinks.Field(
description="The first label",
)
label_2: synalinks.Score = synalinks.Field(
description="The second label",
)
label_3: synalinks.Score = synalinks.Field(
description="The third label",
)
Compilation example:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
average
|
str
|
Type of averaging to be performed across per-class results
in the multi-class case.
Acceptable values are |
None
|
beta
|
float
|
Determines the weight of given to recall
in the harmonic mean between precision and recall (see pseudocode
equation above). Defaults to |
1.0
|
threshold
|
float
|
(Optional) Float representing the threshold for deciding
whether prediction values are 1 or 0. Elements of |
0.5
|
name
|
str
|
(Optional) string name of the metric instance. |
'binary_fbeta_score'
|
in_mask
|
list
|
(Optional) list of keys to keep to compute the metric. |
None
|
out_mask
|
list
|
(Optional) list of keys to remove to compute the metric. |
None
|
in_mask_pattern
|
str
|
(Optional) Regex pattern; fields whose names match
are kept (combined with |
None
|
out_mask_pattern
|
str
|
(Optional) Regex pattern; fields whose names match
are dropped (combined with |
None
|
Source code in synalinks/src/metrics/f_score_metrics.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | |
get_config()
Return the serializable config of the metric.
Returns:
| Type | Description |
|---|---|
dict
|
The config dict. |